
package com.shop.cloud.mall.api.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.mall.api.service.GoodsRecommendService;
import com.shop.cloud.mall.common.entity.GoodsRecommend;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 商品推荐
 *
 * @author
 * @date 2023-10-16 10:25:37
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/goodsrecommend")
@Tag(description = "goodsrecommend", name = "商品推荐api")
public class GoodsRecommendController {

    private final GoodsRecommendService goodsRecommendService;

    /**
     * 通过spuId查询商品推荐
     * @param spuId
     * @return R
     */
    @Operation(summary = "通过spuId查询商品推荐")
    @GetMapping("/spu/{spuid}")
    public R getById(@PathVariable("spuid") String spuId) {
        return R.ok(goodsRecommendService.getOne(Wrappers.<GoodsRecommend>query().lambda()
                .eq(GoodsRecommend::getSpuId, spuId)));
    }

}
